/*!
 * \file amqp_basedata_type.h
 *
 * \brief amqp 解析 私有数据类型
 *
 * All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.\n
 *
 * \version 2.0
 * \author geyh
 * \date 2015/12/24
 *
 */

#ifndef __AMQP_BASEDATA_TYPE_H_
#define __AMQP_BASEDATA_TYPE_H_

#include "frlist.h"
#include "frreport_comm.h"
#include "frbyte_buffer.h"

typedef struct __st_amqp_private
{
    //session
    char *p_title;

    char *p_content_type;
    char *p_content_encoding;

    int is_message;

    int is_topic;
    int i_flag_report;
    int i_use_request;

    unsigned long ul_seq;

    L4_transaction st_l4_trans;

    Frlist_header *p_lst_comm_tmp;                          //数据  activeMQ comm
    Frlist_header *p_lst_req_tmp;                          //数据  activeMQ req
    Frlist_header *p_lst_mq_tmp;

    Frreport_body_data *p_st_body_data_req;
    Frreport_body_data *p_st_body_data_resp;

    int i_id_first;
    int i_id_last;
    int i_refence;

    char *p_exchange;
    char *p_queue;
    char *p_routing_key;
    char *p_exchange_type;
    char *p_consumer_tag;
    int i_message_size;

}st_amqp_private_data;



typedef struct __L7session_amqp_private
{
    Frlist_header st_session_private;    //对应多个包情况 存放 st_amqp_private_data
    st_amqp_private_data *p_st_private;  //私有数据
    Frbyte_Packet *p_st_data;            // 数据内容

    char arr_session_id[APM_UUID_SIZE];
    struct timeval st_login_timestamp;
    char *p_user_name;
    char *p_server;
    int i_flag_data_type;
    int i_version;

}L7session_amqp_private;

/* 4位小头节序转到本地字节序 */
#define pntohi(p)  ((unsigned int)*((const unsigned char *)(p + 0)) << 24 | \
                    (unsigned int)*((const unsigned char *)(p + 1)) << 16 | \
                    (unsigned int)*((const unsigned char *)(p + 2)) << 8 | \
                    (unsigned int)*((const unsigned char *)(p + 3)) << 0)

/* 2位小头节序转到本地字节序 */
#define pntohs(p)  ((unsigned short)*((const unsigned char *)(p + 0)) << 8 | \
                    (unsigned short)*((const unsigned char *)(p + 1)) << 0)

#endif //__AMQP_BASEDATA_TYPE_H_
